const detail = this.getApiPage().getApiWidgetsByClassName('falseAlarm')
const box_5 = this.pageObj.getApiWidgetByAliasName('box_5')
const form = this.getApiPage().retrievePlugin('base-forms')

// 渲染弹窗
box_5.widgetObj._option.links.text = '提示：是否为误警事件？'
box_5.widgetObj.render()

// 重置表单
form.resetForm('form_14')

// 获取事件 ID
const judgeForm = this.pageObj.getApiWidgetByAliasName('judge-content').widgetObj
const id = judgeForm._option.dataSource.id
console.log('judgeForm', judgeForm)

// 修改事件状态
form.setFormData('form_14', { id, whetherProcess: '4' })

detail.forEach(v => v.showWidget())

///////////////////////////////////////////////////////////////////

const form = this.getApiPage().retrievePlugin('base-forms')
const data = form.getFormData('form_14')
console.log('save', data)
const options = {
  method: 'POST',
  headers: {
    "Content-type": "application/json",
  },
  body: JSON.stringify({ ...data })
}

fetch('/Event/event/updateEvent', options)
  .then(res => res.json())
  .then(json => {
    console.log(json);
    if (json?.resultCode === '000000') {
      const falseAlarm = this.getApiPage().getApiWidgetsByClassName('falseAlarm')
      falseAlarm.forEach(v => v.hideWidget())
      const detail = this.getApiPage().getApiWidgetsByClassName('detail')
      detail.forEach(v => v.hideWidget())
      const event_list = this.pageObj.getApiWidgetByAliasName('event-list')
      event_list.widgetObj.currentPanelShow = false
      const gis = this.getApiPage().getApiWidgetByAliasName('三维组件')
      gis.widgetObj.setIconPosition({ right: 20, top: 100 })
      gis.widgetObj.setModalPosition({ right: 405, bottom: 20 })
      gis.widgetObj.sullivan.initial();
      this.getApiPage().setVariables([{ name: 'update', value: new Date().toLocaleTimeString() }])
    }
  })

///////////////////////////////////////////////////////////////////////////////

// 获取事件 ID
const judgeForm = this.pageObj.getApiWidgetByAliasName('judge-content').widgetObj
const id = judgeForm._option.dataSource.id

$event?.(id)
  .then(({success} = {}) => {
    console.log(success);
    if (success) {
      const detail = this.getApiPage().getApiWidgetsByClassName('detail')
      detail.forEach(v => v.hideWidget())

      const event_list = this.pageObj.getApiWidgetByAliasName('event-list')
      event_list.widgetObj.currentPanelShow = false

      // 重置三维组件位置
      const gis = this.getApiPage().getApiWidgetByAliasName('三维组件')
      gis.widgetObj.setIconPosition({ right: 20, top: 100 })
      gis.widgetObj.setModalPosition({ right: 405, bottom: 20 })
      gis.widgetObj.sullivan.initial();

      // 刷新数据
      this.getApiPage().setVariables([{ name: 'update', value: new Date().toLocaleTimeString() }])
    }
  })

